Skip to content

Conversation

@ahmed-n-abdeltwab
Copy link
Contributor

@ahmed-n-abdeltwab ahmed-n-abdeltwab commented May 18, 2025

Description:
This PR integrates OpenAPI support into the Rocket.Chat API, migrate of Rocket.Chat API endpoints to the new OpenAPI pattern. The update includes improved API documentation, enhanced type safety, and response validation using AJV.

Key Changes:

  • Implemented the new pattern and added AJV-based JSON schema validation for API.
  • Uses the ExtractRoutesFromAPI utility from the TypeScript definitions to dynamically derive the routes from the endpoint specifications.
  • Enabled Swagger UI integration for this API.
  • This does not introduce any breaking changes to the endpoint logic.

Issue Reference:
Relates to #34983, part of the ongoing OpenAPI integration effort.

Testing:

  • Verified that the API response schemas are correctly documented in Swagger UI.

  • All tests passed without any breaking changes

Endpoint:

Looking forward to your feedback! 🚀

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented May 18, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented May 18, 2025

🦋 Changeset detected

Latest commit: b195084

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/network-broker Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@rocket.chat/apps Patch
@rocket.chat/freeswitch Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ahmed-n-abdeltwab ahmed-n-abdeltwab marked this pull request as ready for review May 20, 2025 18:24
@ahmed-n-abdeltwab
Copy link
Contributor Author

ahmed-n-abdeltwab commented May 25, 2025

While analyzing the API behavior using Wireshark, I observed that invoking the endpoint http://localhost:3000/api/v1/chat.pinMessage with the POST method results in duplicate HTTP requests. This behavior could potentially impact the API's performance negatively.

Here is the relevant data from the Wireshark capture:

No.	Time	Source	Destination	Protocol	Length	Info
464	45.233730502	127.0.0.1	127.0.0.1	HTTP/JSON	326	POST /api/v1/chat.pinMessage HTTP/1.1 , JavaScript Object Notation (application/json)
469	45.475257994	127.0.0.1	127.0.0.1	HTTP/JSON	461	POST /api/v1/chat.pinMessage HTTP/1.1 , JavaScript Object Notation (application/json)
476	45.483759311	127.0.0.1	127.0.0.1	HTTP/JSON	71	HTTP/1.1 400 Bad Request , JavaScript Object Notation (application/json)
478	45.492740022	127.0.0.1	127.0.0.1	HTTP/JSON	804	HTTP/1.1 400 Bad Request , JavaScript Object Notation (application/json)

I'm not sure if the repeated requests and responses are intentional or an issue, but I wanted to bring it to your attention.

@codecov
Copy link

codecov bot commented May 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.56%. Comparing base (470753a) to head (b195084).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #36020      +/-   ##
===========================================
- Coverage    65.84%   65.56%   -0.29%     
===========================================
  Files         3186     3106      -80     
  Lines       106663   105371    -1292     
  Branches     20311    19998     -313     
===========================================
- Hits         70237    69091    -1146     
+ Misses       33763    33675      -88     
+ Partials      2663     2605      -58     
Flag Coverage Δ
e2e 56.91% <ø> (-1.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahmed-n-abdeltwab ahmed-n-abdeltwab force-pushed the feat/openapi-chat-pinMessage branch from 06e4be5 to 290c1aa Compare July 28, 2025 16:26

reactions?: {
[key: string]: { names?: (string | undefined)[]; usernames: string[]; federationReactionEventIds?: Record<string, string> };
[key: string]: { names?: string[]; usernames: string[]; federationReactionEventIds?: Record<string, string> };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working with Typia to generate schemas for IMessage. I ran into an error with this type undefined. typia doesnt allow undefined inside the interface

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmed-n-abdeltwab ahmed-n-abdeltwab marked this pull request as ready for review July 29, 2025 14:36
@ahmed-n-abdeltwab ahmed-n-abdeltwab requested review from a team as code owners July 29, 2025 14:36
@cardoso cardoso added this to the 7.10.0 milestone Jul 29, 2025
@cardoso cardoso added the stat: QA assured Means it has been tested and approved by a company insider label Jul 29, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 29, 2025
@ggazzo ggazzo merged commit c5f0be1 into RocketChat:develop Jul 29, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gsoc-project stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants